//
//  WViewController.m
//  测试111
//
//  Created by Burn on 2018/10/17.
//  Copyright © 2018年 buren. All rights reserved.
//

#import "WViewController.h"
#import "RootTabBarViewController.h"


@interface WViewController ()

@end

static NSInteger myIndex = 1;

@implementation WViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    RootTabBarViewController *tabbrVC = (RootTabBarViewController *)self.navigationController.tabBarController;
    //  每次进来的时候tabbrVC.index刷新数据
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255) / 255.0 green:arc4random_uniform(255) / 255.0 blue:arc4random_uniform(255) / 255.0 alpha:1];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changeContent:) name:@"CHANGECONTENT" object:nil];
    
    RootTabBarViewController *tabbrVC = (RootTabBarViewController *)self.navigationController.tabBarController;
    NSLog(@"%ld",tabbrVC.index);
}

- (void)changeContent:(NSNotification *)noti{
    NSDictionary *dic = noti.userInfo;
    NSInteger itemIndex = [dic[@"itemIndex"] integerValue];
    NSInteger btnIndex = [dic[@"btnIndex"] integerValue];
    
    if (myIndex == itemIndex) {
        //  根据 btnIndex 刷新数据
    }
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}

@end
